<template>
    <div>
        <div :style="{padding: '24px', minHeight: '480px', background: '#fff'}">
            <el-row v-if="bind">
                已绑定，解绑请联系管理员
            </el-row>
            <template v-if="!bind">
                <el-row>
                    <div>打开微信，扫描二维码，一个微信只能绑定一个账号 </div>
                    <img :src="genUrl" />
                </el-row>
            </template>
        </div>
    </div>
</template>
<script>
import api from '@/api/api';
export default {
    name: 'WeiXin',
    data() {
        return {
            loading: false,
            bind: false,
            key: "",
            qrurl: "",
            code: "",

        };
    },
    mounted: function() {

        this.getDetail();

    },
    computed: {
        genUrl: function() {
            return "http://qr.liantu.com/api.php?w=200&text=" + this.qrurl;
        }
    },
    methods: {

        getDetail: function() {

            var me = this;
            me.showLoading();
            me.$http.post("/merchant/weixin.do").then(response => {
                var body = response;
                if (body.status == 0) {
                    me.bind = true;
                } else if (body.status == 3) {
                    me.bind = false;
                    me.qrurl = body.obj;
                } else {
                    me.errorMessage(body.info);
                }
                me.hideLoading();
            }, response => {
                me.hideLoading();
            });
        }

    }
}
</script>
<style scoped>
</style>